<?php

if (!defined('BASEPATH')) exit('No direct script access allowed');



require FCPATH.'branch/fqb/D_Common.php';

class M_Controller extends D_Common {

    // 系统体检选项
    protected function _get_step() {
        return array(
            1  => '_cookie_code',
            2  => '_admin_file',
            3  => '_dir_write',
            4  => '_template_theme',
            5  => '_url_fopen',
            6  => '_curl_init',
            7  => '_fsockopen',
            8  => '_php',
            9  => '_mysql',
            10 => '_email',
            11 => '_memcache',
            12 => '_mcryp',
            13 => '_tableinfo',
            14 => '_unzip',
            15 => '_category',
            16 => '_openssl_open',
            17 => '_gzinflate',
            18 => '_ini_get',
            19 => '_template',
            20 => '_upload',
            21 => '_domain',
            22 => '_always_populate_raw_post_data',
            23 => '_attachment_unused',
            24 => '_zend',
            25 => '_ctype',
            26 => '_web_template',
            27 => '_database',
            28 => '_update',
            29 => '_webpath',
            30 => '_category_dir',
            31 => '_lang',
            98 => '_version',
            99 => '_result'
        );
    }

    // 更新栏目数据
    protected function _update_category_total() {
        $mod = array(
            'share',
        );
        $module = $this->db->where('disabled', 0)->order_by('displayorder ASC')->get('module')->result_array();
        if ($module) {
            foreach ($module as $t) {
                $mod[] = $t['dirname'];
            }
        }
        foreach ($this->site_info as $siteid => $t) {
            foreach ($mod as $dirname) {
                $cache = $this->dcache->get('module-'.$siteid.'-'.$dirname);
                if (!$cache['category']) {
                    continue;
                }
                $table = $this->db->dbprefix($siteid . '_' . $dirname . '_category');
                if (!$this->db->query("SHOW TABLES LIKE '".$table."'")->row_array()) {
                    continue;
                }
                //
                foreach ($cache['category'] as $i => $c) {
                    if ($c['mid']) {
                        $cache['category'][$i]['total'] = $this->db->where('status', 9)->where('catid', $c['id'])->count_all_results($siteid.'_'.$c['mid'].'_index');
                    } else {
                        $cache['category'][$i]['total'] = 0;
                    }
                }
                foreach ($cache['category'] as $i => $c) {
                    if ($c['child']) {
                        $arr = explode(',', $c['childids']);
                        $cache['category'][$c['id']]['total'] = intval($cache['category'][$c['id']]['total']);
                        foreach ($arr as $i) {
                            $cache['category'][$c['id']]['total']+= $cache['category'][$i]['total'];
                        }
                    }
                }
                $this->dcache->set('module-'.$siteid.'-'.$dirname, $cache);
            }
        }
    }

    public function aaa() {
        echo 'This is FYCMS v'.DR_VERSION;
    }

    public function abc() {
        echo DR_LICENSE_ID;exit;
    }
}